package com.engine.cn.sigletom;

public class HungrySingleton {
    private static final HungrySingleton INSTANCE = new HungrySingleton();

    //私有化构造器
    private HungrySingleton() {
        System.out.println("单例模式实例创建");
    }

    //公开访问点
    public static HungrySingleton getInstance() {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        return INSTANCE;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                HungrySingleton singleton = HungrySingleton.getInstance();
                System.out.println("线程编号==>" + singleton);
            }
            ).start();
        }
    }
}
